/**
 * 
 */
package com.probiz.estore.eai.common;

import java.io.File;
import java.io.FileFilter;

/**
 * @author pengzhirong
 * 
 */
public class XmlFileFilter implements FileFilter {

	private static String SUFFIX = ".xml";
	
	private String fileNamePrefix = null;
	
	public XmlFileFilter(String fileNamePrefix) {
		this.fileNamePrefix = fileNamePrefix;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see java.io.FileFilter#accept(java.io.File)
	 */
	public boolean accept(File file) {
		//前缀判断时，注意文件名saleorder_2009、saleorderExport_2009的区分
		return !file.isHidden() && file.getName().endsWith(SUFFIX) 
				&& ( file.getName().startsWith(fileNamePrefix) && (file.getName().length()>fileNamePrefix.length()?file.getName().startsWith(fileNamePrefix+"_"):true));
	}
}
